import { computed, ref } from 'vue'

export default function useDialog(initialWidth = '640px') {
    const width = ref(initialWidth)
    const visible = ref(false)
    const FormRef = ref(null)
    const mode = ref('add')
    const loading = ref(false)
    const pk = ref(null)

    // 增加操作类型映射
    const operationMap = computed(() => ({
        add: { title: '新增', action: '创建' },
        edit: { title: '编辑', action: '修改' }
    }))

    return {
        FormRef,
        width,
        visible,
        mode,
        loading,
        pk,
        title: computed(() => operationMap.value[mode.value]?.title),
        actionName: computed(() => operationMap.value[mode.value]?.action)
    }
}
